<?php
//Let's define some variables for use with our mysql function
$host = "host";
$user = "username";
$pass = "password";
$db = "database";

//We create a function to handle mysql connections
function connectdb()
{
global $host, $user, $pass, $db;

$link = mysql_connect($host, $user, $pass);
if(!$link) {
echo "An error has occured! ".die(mysql_error());
}

$db_select = mysql_select_db($db, $link);

if(!$db_select) {
echo "An error has occured: ".die(mysql_error());

}
}

?>
